#include "AdminAddAdminWindow.h"
#include "ui_AdminAddAdminWindow.h"

AdminAddAdminWindow::AdminAddAdminWindow(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::AdminAddAdminWindow)
{
    ui->setupUi(this);
    this->setWindowTitle("添加管理员");
}

AdminAddAdminWindow::~AdminAddAdminWindow()
{
    delete ui;
}

void AdminAddAdminWindow::replyShowAdminAddAdminWindow(){
    this->show();
}

//确认添加新管理员按钮
void AdminAddAdminWindow::on_add_btn_clicked(){
    User user;  //新的管理员
    UserTable user_table;   //操作表user_table
    /**
      * @leiteorz
      * 从ui界面获取新的管理员实体
      */
    user.name = ui->name_et->toPlainText();
    user.account = ui->account_et->toPlainText();
    user.category = 1;
    user.password = ui->password_et->toPlainText();
    user.phone_num = "10086";
    //将新的管理员添加到数据库中
    user_table.insertUser(user);
    //消失
    this->hide();
}
